using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Cirrious.MvvmCross.Binding.Droid;
using Cirrious.MvvmCross.Droid.Platform;
using Cirrious.MvvmCross.Interfaces.Plugins;
using Cirrious.MvvmCross.Platform;
using Cirrious.MvvmCross.Interfaces.ViewModels;
using Cirrious.MvvmCross.Interfaces.Views;
using Cirrious.MvvmCross.Application;
using Cirrious.MvvmCross.ExtensionMethods;
using TeaLightV5.Foundation.MvvmCross.Application;
using Cirrious.MvvmCross.Droid.Views;
using TeaLightV5.Foundation.Ux.MvvmCross.Droid.Views;

namespace TeaLightV5.Foundation.UX.Droid.Platform
{
    public abstract class TeaBaseAndroidSetup : MvxBaseAndroidBindingSetup
    {
        protected TeaBaseAndroidSetup(Context applicationContext)
            : base(applicationContext)
        {
        }

        protected override void InitializeDefaultTextSerializer()
        {
            TeaLightV5.Foundation.MvvmCross.Plugins.Json.PluginLoader.Instance.EnsureLoaded();
        }

        protected override void InitializeViewModelFramework()
        {
            this.RegisterServiceType<IMvxViewModelLoader, TeaViewModelLoader>();
            this.RegisterServiceType<IMvxViewModelLocatorAnalyser, MvxViewModelLocatorAnalyser>();
        }

        protected override IMvxPluginManager CreatePluginManager()
        {
            var toReturn = new MvxLoaderBasedPluginManager();
            var registry = new MvxLoaderPluginRegistry(".Droid", toReturn.Loaders);
            AddPluginsLoaders(registry);
            return toReturn;
        }

        protected virtual void AddPluginsLoaders(MvxLoaderPluginRegistry loaders)
        {
            // none added by default
        }

        protected override MvxAndroidViewsContainer CreateViewsContainer(Context applicationContext)
        {
            return new TeaAndroidViewsContainer(applicationContext);
        }
    }
}